
//
//  TestingViewController.m
//  LearnObjectiveC
//
//  Created by 吴可高 on 16/5/5.
//  Copyright © 2016年 吴可高. All rights reserved.

#import "TestingViewController.h"
#import "OOBaseNavigaionController.h"
#import "HomePageContentView.h"
#import "ColumeBarController.h"

#import "MyCenterController.h"
#import "UtilityTool.h"
#import "PickerViewManager.h"
#import "UIAlertView+AFNetworking.h"
#import "NSString+Path.h"
#import "AccountRequestTool.h"


#import "AccountRequestTool.h"
#import <AudioToolbox/AudioToolbox.h>
@interface TestingViewController()<UITableViewDataSource,UITableViewDelegate>
{
   
}

@property (strong, nonatomic) HomePageContentView * homePageContentView;
@property (strong, nonatomic) MyCenterController * centerController;
@property (weak, nonatomic) UIButton  * normalStateButton;
@property (strong, nonatomic) UIView  * edgeView;
@property (strong, nonatomic) NSArray * pickerItems;
@property (strong, nonatomic) PickerViewManager * pickerViewManager;
@property (strong, nonatomic) NSURLSession * session;
@property (assign, nonatomic) SystemSoundID  systemSoundID;

@property (weak, nonatomic) UITableView * tableView;
@property (strong, nonatomic) NSArray<NSString *>*items;
@end

@implementation TestingViewController

-(void)viewDidLoad
{
 
     [super viewDidLoad];
     self.view.backgroundColor = [UIColor whiteColor];
    [self initWithControllerSubjectView];
//     [self initSubObjectViews];
//     [self initData];
    [self alertViewAddObersversRequestStatus];
}

-(void)initData
{
    self.items = @[@"itme0",@"itme1",@"itme2",@"itme3",@"itme4",@"itme5",];
    /**
     
     
     - returns:
     */
}

-(void)initSubObjectViews
{
    self.edgesForExtendedLayout = UIRectEdgeNone;
     UITableView * tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, kNavigationBarHeight, kScreen_Width, kScreen_Height-kNavigationBarHeight) style:UITableViewStylePlain];
    tableView.delegate = self;
    tableView.dataSource = self;
    _tableView = tableView;
    [self.view addSubview:_tableView];
}

-(void)alertViewAddObersversRequestStatus
{
    [AccountRequestTool areaCityDataRequest:@"/hxmc-app/provincialCity/levelThreeArea" success:^(NSString *msg, id responseObject) {
        _pickerViewManager.items = responseObject;
    } failure:^(NSError *error) {
        
    }];
   
}

-(void)initWithNavigationBarStyle
{
    [self customNavigationBarStyleWithleftBarItems:@[@"",@""] navigationItemTitle:@"testVC" andRightBarButtonItems:@[@"jump",@""] leftBarItemHandleComplete:^(NSInteger idx, UIButton *parameter) {
        
    }rightBarItemHanbleComplete:^(NSInteger idx, UIButton *parameter)
     {
     }];
    [self setNavigationItemTitle:@"testVC"];
}

-(void)initWithControllerSubjectView
{
    CGRect edgeBounds = UIEdgeInsetsInsetRect(self.view.bounds, UIEdgeInsetsMake(100, 0, 100, 0));
    PickerViewManager * pickerViewManager  = [[PickerViewManager alloc]initWithPickerViewSourceModel:nil frame:edgeBounds  andresponseBlcok:^(NSString *item1, NSString *item2, NSString *item3) {
    }];
    [self.view addSubview:pickerViewManager.pickerView];
    _pickerViewManager  =  pickerViewManager;
}

#pragma mark - UITableViewDelegate DataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [[self items]count];
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * resueIndefiner = @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:resueIndefiner];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:resueIndefiner];
    }
    cell.textLabel.text = [[self items]objectAtIndex:indexPath.row];
    return cell;
}


- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
    [self tableView:tableView accessoryButtonTappedForRowWithIndexPath:indexPath];
    return indexPath;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    ColumeBarController * columeBarController = [[ColumeBarController alloc]init];
    [self.navigationController pushViewController:columeBarController animated:YES];
    
}
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"(indexPath = %@)",indexPath);
}

-(void)dealloc
{
    NSLog(@" TestingViewController dealloc");
}

-(void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
}

@end
